home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / daemons / nfs / nfs-serv.2be / nfs-serv / nfs-server-2.2beta16 / nfs_prot.x < prev    next >
Encoding:
Text File  |  1995-05-14  |  7.7 KB  |  365 lines

  1. %/*
  2. % * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  3. % * unrestricted use provided that this legend is included on all tape
  4. % * media and as a part of the software program in whole or part.  Users
  5. % * may copy or modify Sun RPC without charge, but are not authorized
  6. % * to license or distribute it to anyone else except as part of a product or
  7. % * program developed by the user or with the express written consent of
  8. % * Sun Microsystems, Inc.
  9. % *
  10. % * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  11. % * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  12. % * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13. % *
  14. % * Sun RPC is provided with no support and without any obligation on the
  15. % * part of Sun Microsystems, Inc. to assist in its use, correction,
  16. % * modification or enhancement.
  17. % *
  18. % * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19. % * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20. % * OR ANY PART THEREOF.
  21. % *
  22. % * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  23. % * or profits or other special, indirect and consequential damages, even if
  24. % * Sun has been advised of the possibility of such damages.
  25. % *
  26. % * Sun Microsystems, Inc.
  27. % * 2550 Garcia Avenue
  28. % * Mountain View, California  94043
  29. % */
  30.  
  31. %/*
  32. % * Copyright (c) 1987, 1990 by Sun Microsystems, Inc.
  33. % */
  34. %
  35. %/* from @(#)nfs_prot.x    1.3 91/03/11 TIRPC 1.0 */
  36.  
  37. #ifdef RPC_HDR
  38. %#ifndef _rpcsvc_nfs_prot_h
  39. %#define _rpcsvc_nfs_prot_h
  40. #endif
  41.  
  42. const NFS_PORT          = 2049;
  43. const NFS_MAXDATA       = 8192;
  44. const NFS_MAXPATHLEN    = 1024;
  45. const NFS_MAXNAMLEN    = 255;
  46. const NFS_FHSIZE    = 32;
  47. const NFS_COOKIESIZE    = 4;
  48. const NFS_FIFO_DEV    = -1;    /* size kludge for named pipes */
  49.  
  50. /*
  51.  * File types
  52.  */
  53. const NFSMODE_FMT  = 0170000;    /* type of file */
  54. const NFSMODE_DIR  = 0040000;    /* directory */
  55. const NFSMODE_CHR  = 0020000;    /* character special */
  56. const NFSMODE_BLK  = 0060000;    /* block special */
  57. const NFSMODE_REG  = 0100000;    /* regular */
  58. const NFSMODE_LNK  = 0120000;    /* symbolic link */
  59. const NFSMODE_SOCK = 0140000;    /* socket */
  60. const NFSMODE_FIFO = 0010000;    /* fifo */
  61.  
  62. /*
  63.  * Error status
  64.  */
  65. enum nfsstat {
  66.     NFS_OK= 0,        /* no error */
  67.     NFSERR_PERM=1,        /* Not owner */
  68.     NFSERR_NOENT=2,        /* No such file or directory */
  69.     NFSERR_IO=5,        /* I/O error */
  70.     NFSERR_NXIO=6,        /* No such device or address */
  71.     NFSERR_ACCES=13,    /* Permission denied */
  72.     NFSERR_EXIST=17,    /* File exists */
  73.     NFSERR_NODEV=19,    /* No such device */
  74.     NFSERR_NOTDIR=20,    /* Not a directory*/
  75.     NFSERR_ISDIR=21,    /* Is a directory */
  76.     NFSERR_FBIG=27,        /* File too large */
  77.     NFSERR_NOSPC=28,    /* No space left on device */
  78.     NFSERR_ROFS=30,        /* Read-only file system */
  79.     NFSERR_NAMETOOLONG=63,    /* File name too long */
  80.     NFSERR_NOTEMPTY=66,    /* Directory not empty */
  81.     NFSERR_DQUOT=69,    /* Disc quota exceeded */
  82.     NFSERR_STALE=70,    /* Stale NFS file handle */
  83.     NFSERR_WFLUSH=99    /* write cache flushed */
  84. };
  85.  
  86. /*
  87.  * File types
  88.  */
  89. enum ftype {
  90.     NFNON = 0,    /* non-file */
  91.     NFREG = 1,    /* regular file */
  92.     NFDIR = 2,    /* directory */
  93.     NFBLK = 3,    /* block special */
  94.     NFCHR = 4,    /* character special */
  95.     NFLNK = 5,    /* symbolic link */
  96.     NFSOCK = 6,    /* unix domain sockets */
  97.     NFBAD = 7,    /* unused */
  98.     NFFIFO = 8     /* named pipe */
  99. };
  100.  
  101. /*
  102.  * File access handle
  103.  */
  104. struct nfs_fh {
  105.     opaque data[NFS_FHSIZE];
  106. };
  107.  
  108. /* 
  109.  * Timeval
  110.  */
  111. struct nfstime {
  112.     unsigned seconds;
  113.     unsigned useconds;
  114. };
  115.  
  116.  
  117. /*
  118.  * File attributes
  119.  */
  120. struct fattr {
  121.     ftype type;        /* file type */
  122.     unsigned mode;        /* protection mode bits */
  123.     unsigned nlink;        /* # hard links */
  124.     unsigned uid;        /* owner user id */
  125.     unsigned gid;        /* owner group id */
  126.     unsigned size;        /* file size in bytes */
  127.     unsigned blocksize;    /* prefered block size */
  128.     unsigned rdev;        /* special device # */
  129.     unsigned blocks;    /* Kb of disk used by file */
  130.     unsigned fsid;        /* device # */
  131.     unsigned fileid;    /* inode # */
  132.     nfstime    atime;        /* time of last access */
  133.     nfstime    mtime;        /* time of last modification */
  134.     nfstime    ctime;        /* time of last change */
  135. };
  136.  
  137. /*
  138.  * File attributes which can be set
  139.  */
  140. struct sattr {
  141.     unsigned mode;    /* protection mode bits */
  142.     unsigned uid;    /* owner user id */
  143.     unsigned gid;    /* owner group id */
  144.     unsigned size;    /* file size in bytes */
  145.     nfstime    atime;    /* time of last access */
  146.     nfstime    mtime;    /* time of last modification */
  147. };
  148.  
  149.  
  150. typedef string filename<NFS_MAXNAMLEN>; 
  151. typedef string nfspath<NFS_MAXPATHLEN>;
  152.  
  153. /*
  154.  * Reply status with file attributes
  155.  */
  156. union attrstat switch (nfsstat status) {
  157. case NFS_OK:
  158.     fattr attributes;
  159. default:
  160.     void;
  161. };
  162.  
  163. struct sattrargs {
  164.     nfs_fh file;
  165.     sattr attributes;
  166. };
  167.  
  168. /*
  169.  * Arguments for directory operations
  170.  */
  171. struct diropargs {
  172.     nfs_fh    dir;    /* directory file handle */
  173.     filename name;        /* name (up to NFS_MAXNAMLEN bytes) */
  174. };
  175.  
  176. struct diropokres {
  177.     nfs_fh file;
  178.     fattr attributes;
  179. };
  180.  
  181. /*
  182.  * Results from directory operation
  183.  */
  184. union diropres switch (nfsstat status) {
  185. case NFS_OK:
  186.     diropokres diropres;
  187. default:
  188.     void;
  189. };
  190.  
  191. union readlinkres switch (nfsstat status) {
  192. case NFS_OK:
  193.     nfspath data;
  194. default:
  195.     void;
  196. };
  197.  
  198. /*
  199.  * Arguments to remote read
  200.  */
  201. struct readargs {
  202.     nfs_fh file;        /* handle for file */
  203.     unsigned offset;    /* byte offset in file */
  204.     unsigned count;        /* immediate read count */
  205.     unsigned totalcount;    /* total read count (from this offset)*/
  206. };
  207.  
  208. /*
  209.  * Status OK portion of remote read reply
  210.  */
  211. struct readokres {
  212.     fattr    attributes;    /* attributes, need for pagin*/
  213.     opaque data<NFS_MAXDATA>;
  214. };
  215.  
  216. union readres switch (nfsstat status) {
  217. case NFS_OK:
  218.     readokres reply;
  219. default:
  220.     void;
  221. };
  222.  
  223. /*
  224.  * Arguments to remote write 
  225.  */
  226. struct writeargs {
  227.     nfs_fh    file;        /* handle for file */
  228.     unsigned beginoffset;    /* beginning byte offset in file */
  229.     unsigned offset;    /* current byte offset in file */
  230.     unsigned totalcount;    /* total write count (to this offset)*/
  231.     opaque data<NFS_MAXDATA>;
  232. };
  233.  
  234. struct createargs {
  235.     diropargs where;
  236.     sattr attributes;
  237. };
  238.  
  239. struct renameargs {
  240.     diropargs from;
  241.     diropargs to;
  242. };
  243.  
  244. struct linkargs {
  245.     nfs_fh from;
  246.     diropargs to;
  247. };
  248.  
  249. struct symlinkargs {
  250.     diropargs from;
  251.     nfspath to;
  252.     sattr attributes;
  253. };
  254.  
  255.  
  256. typedef opaque nfscookie[NFS_COOKIESIZE];
  257.  
  258. /*
  259.  * Arguments to readdir
  260.  */
  261. struct readdirargs {
  262.     nfs_fh dir;        /* directory handle */
  263.     nfscookie cookie;
  264.     unsigned count;        /* number of directory bytes to read */
  265. };
  266.  
  267. struct entry {
  268.     unsigned fileid;
  269.     filename name;
  270.     nfscookie cookie;
  271.     entry *nextentry;
  272. };
  273.  
  274. struct dirlist {
  275.     entry *entries;
  276.     bool eof;
  277. };
  278.  
  279. union readdirres switch (nfsstat status) {
  280. case NFS_OK:
  281.     dirlist reply;
  282. default:
  283.     void;
  284. };
  285.  
  286. struct statfsokres {
  287.     unsigned tsize;    /* preferred transfer size in bytes */
  288.     unsigned bsize;    /* fundamental file system block size */
  289.     unsigned blocks;    /* total blocks in file system */
  290.     unsigned bfree;    /* free blocks in fs */
  291.     unsigned bavail;    /* free blocks avail to non-superuser */
  292. };
  293.  
  294. union statfsres switch (nfsstat status) {
  295. case NFS_OK:
  296.     statfsokres reply;
  297. default:
  298.     void;
  299. };
  300.  
  301. /*
  302.  * Remote file service routines
  303.  */
  304. program NFS_PROGRAM {
  305.     version NFS_VERSION {
  306.         void 
  307.         NFSPROC_NULL(void) = 0;
  308.  
  309.         attrstat 
  310.         NFSPROC_GETATTR(nfs_fh) =    1;
  311.  
  312.         attrstat 
  313.         NFSPROC_SETATTR(sattrargs) = 2;
  314.  
  315.         void 
  316.         NFSPROC_ROOT(void) = 3;
  317.  
  318.         diropres 
  319.         NFSPROC_LOOKUP(diropargs) = 4;
  320.  
  321.         readlinkres 
  322.         NFSPROC_READLINK(nfs_fh) = 5;
  323.  
  324.         readres 
  325.         NFSPROC_READ(readargs) = 6;
  326.  
  327.         void 
  328.         NFSPROC_WRITECACHE(void) = 7;
  329.  
  330.         attrstat
  331.         NFSPROC_WRITE(writeargs) = 8;
  332.  
  333.         diropres
  334.         NFSPROC_CREATE(createargs) = 9;
  335.  
  336.         nfsstat
  337.         NFSPROC_REMOVE(diropargs) = 10;
  338.  
  339.         nfsstat
  340.         NFSPROC_RENAME(renameargs) = 11;
  341.  
  342.         nfsstat
  343.         NFSPROC_LINK(linkargs) = 12;
  344.  
  345.         nfsstat
  346.         NFSPROC_SYMLINK(symlinkargs) = 13;
  347.  
  348.         diropres
  349.         NFSPROC_MKDIR(createargs) = 14;
  350.  
  351.         nfsstat
  352.         NFSPROC_RMDIR(diropargs) = 15;
  353.  
  354.         readdirres
  355.         NFSPROC_READDIR(readdirargs) = 16;
  356.  
  357.         statfsres
  358.         NFSPROC_STATFS(nfs_fh) = 17;
  359.     } = 2;
  360. } = 100003;
  361.  
  362. #ifdef RPC_HDR
  363. %#endif /*!_rpcsvc_nfs_prot_h*/
  364. #endif
  365.